#region Using

using System;
using System.IO;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using BlogEngine.Core;

#endregion

public partial class gallery_settings : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
			BindSettings();

		Page.MaintainScrollPositionOnPostBack = true;
		Page.Title = Resources.labels.settings;

		btnSave.Click += new EventHandler(btnSave_Click);

		btnSave.Text = Resources.labels.saveSettings;
	}

	private void btnSave_Click(object sender, EventArgs e)
	{
		
		//-----------------------------------------------------------------------
		// Gallery Settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.GalleryThumbNailSize = int.Parse(txtGalleryThumbNailSize.Text);
		BlogSettings.Instance.GalleryColumns = int.Parse(txtGalleryColumns.Text);
		BlogSettings.Instance.GalleryRows = int.Parse(txtGalleryRows.Text);

		//-----------------------------------------------------------------------
		// Photo Album Settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.AlbumThumbNailSize = int.Parse(txtAlbumThumbNailSize.Text);
		BlogSettings.Instance.AlbumColumns = int.Parse(txtAlbumColumns.Text);
		BlogSettings.Instance.AlbumRows = int.Parse(txtAlbumRows.Text);

		//-----------------------------------------------------------------------
		// Photo Settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.DefaultPhotoSize = int.Parse(txtPhotoSize.Text);

		//-----------------------------------------------------------------------
		//  Persist settings
		//-----------------------------------------------------------------------
		BlogSettings.Instance.Save();
		Response.Redirect(Request.RawUrl, true);
	}

	private void BindSettings()
	{
		
		//-----------------------------------------------------------------------
		// Gallery Settings
		//-----------------------------------------------------------------------
		txtGalleryThumbNailSize.Text = BlogSettings.Instance.GalleryThumbNailSize.ToString();
		txtGalleryColumns.Text = BlogSettings.Instance.GalleryColumns.ToString();
		txtGalleryRows.Text = BlogSettings.Instance.GalleryRows.ToString();

		//-----------------------------------------------------------------------
		// Photo Album Settings
		//-----------------------------------------------------------------------
		txtAlbumThumbNailSize.Text = BlogSettings.Instance.AlbumThumbNailSize.ToString();
		txtAlbumColumns.Text = BlogSettings.Instance.AlbumColumns.ToString();
		txtAlbumRows.Text = BlogSettings.Instance.AlbumRows.ToString();

		//-----------------------------------------------------------------------
		// Photo Settings
		//-----------------------------------------------------------------------
		txtPhotoSize.Text = BlogSettings.Instance.DefaultPhotoSize.ToString();
	}


}